import pygame
image=pygame.image.load("coffer.jpg")
image.set_colorkey((137,44,75))
import AbstractContainer

class Coffer(AbstractContainer.AbstractContainer):
	def __init__(self,x=0,y=0,locked=False,key=None):
		AbstractContainer.AbstractContainer.__init__(self,x=x,y=y)
		self.locked=locked
		self.key=key
	def getWidth(self):
		return image.get_width()
	def getHeight(self):
		return image.get_height()
	def drawingInformation(self):
		import math
		if self.prev_y==self.y and self.prev_x==self.x:
			im=image
		else:
			r=(self.x-self.prev_x)/(((self.x-self.prev_x)**2+(self.y-self.prev_y)**2)**0.5)
			a=math.acos(r)*180/math.pi
			if self.x-self.prev_x<=0 and self.y-self.prev_y>=0:
				a=180+a
			elif self.x-self.prev_x<=0 and self.y-self.prev_y<=0:
				a=180-a
			elif self.x-self.prev_x>=0 and self.y-self.prev_y<=0:
				a=-a
			im = pygame.transform.rotate(image,a)
		return (self.x-0.5*self.getWidth(),self.y+self.getHeight()),im	
